package com.eoner.baselibrary.bean.aftersale;

import android.support.annotation.NonNull;

import com.eoner.baselibrary.utils.Cn2Spell;

import java.io.Serializable;
import java.util.List;

/**
 * 作者：sean
 * 创建时间：2017/8/27 16:42
 * 功能说明：
 */

public class ShipmentsBean {



    private String code;
    private String msg;
    private DataBean data;
    private ArgsBean args;

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public DataBean getData() {
        return data;
    }

    public void setData(DataBean data) {
        this.data = data;
    }

    public ArgsBean getArgs() {
        return args;
    }

    public void setArgs(ArgsBean args) {
        this.args = args;
    }

    public static class DataBean {
        private List<ShShipmentCompanysBean> sh_shipment_companys;

        public List<ShShipmentCompanysBean> getSh_shipment_companys() {
            return sh_shipment_companys;
        }

        public void setSh_shipment_companys(List<ShShipmentCompanysBean> sh_shipment_companys) {
            this.sh_shipment_companys = sh_shipment_companys;
        }

        public static class ShShipmentCompanysBean implements Serializable,Comparable<ShShipmentCompanysBean> {
            /**
             * sh_initial : H
             * sh_code : huitongkuaidi
             * sh_name : 汇通快递
             */

            private String sh_initial;
            private String sh_code;
            private String sh_name;
            private String pinyin; // 姓名对应的拼音
            private String firstLetter; // 拼音的首字母

            public String getSh_initial() {
                return sh_initial;
            }

            public void setSh_initial(String sh_initial) {
                this.sh_initial = sh_initial;
            }

            public String getSh_code() {
                return sh_code;
            }

            public void setSh_code(String sh_code) {
                this.sh_code = sh_code;
            }

            public String getSh_name() {
                return sh_name;
            }

            public void setSh_name(String sh_name) {
                this.sh_name = sh_name;
                pinyin = Cn2Spell.getPinYin(sh_name); // 根据姓名获取拼音
                firstLetter = pinyin.substring(0, 1).toUpperCase(); // 获取拼音首字母并转成大写
                if (!firstLetter.matches("[A-Z]")) { // 如果不在A-Z中则默认为“#”
                    firstLetter = "#";
                }
            }

            public String getPinyin() {
                return pinyin;
            }

            public String getFirstLetter() {
                return firstLetter;
            }


            @Override
            public int compareTo(@NonNull ShShipmentCompanysBean shShipmentCompanyBean) {
                if (firstLetter.equals("#") && !shShipmentCompanyBean.getFirstLetter().equals("#")) {
                    return 1;
                } else if (!firstLetter.equals("#") && shShipmentCompanyBean.getFirstLetter().equals("#")){
                    return -1;
                } else {
                    return pinyin.compareToIgnoreCase(shShipmentCompanyBean.getPinyin());
                }
            }
        }
    }

    public static class ArgsBean {
        /**
         * cart_num : 1
         * level : 0
         * invite_code :
         * is_partner : 0
         */

        private int cart_num;
        private String level;
        private String invite_code;
        private int is_partner;

        public int getCart_num() {
            return cart_num;
        }

        public void setCart_num(int cart_num) {
            this.cart_num = cart_num;
        }

        public String getLevel() {
            return level;
        }

        public void setLevel(String level) {
            this.level = level;
        }

        public String getInvite_code() {
            return invite_code;
        }

        public void setInvite_code(String invite_code) {
            this.invite_code = invite_code;
        }

        public int getIs_partner() {
            return is_partner;
        }

        public void setIs_partner(int is_partner) {
            this.is_partner = is_partner;
        }
    }
}
